package com.example.demo.pattern.iteratorpattern;

import java.util.Collections;
import java.util.Iterator;

public class MenuItem extends MenuComponent{

    public MenuItem(String name) {
        this.name = name;
    }

    @Override
    protected void print() {
        System.out.println(this.name);
    }

    @Override
    protected Iterator<MenuComponent> iterator() {
        //空迭代器，外部使用不会报错
        return Collections.emptyIterator();
    }
}
